package com.briup.ch10;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @Author briup-adam
 * @Date 2023/10/30 上午8:08
 * @Description
 **/

public class ThreadPoolDemo {

    public static void main(String[] args) {
        // 创建线程池
        ExecutorService pool = Executors.newFixedThreadPool(10);
        //创建任务
        Runnable r=new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i <100 ; i++) {
                    System.out.println(Thread.currentThread().getName()+"："+i);
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        for (int i = 0; i < 15; i++) {
            Future<?> submit = pool.submit(r);
            System.out.println(submit.isDone());
        }

    }
}
